<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="javax.servlet.http.*,
                 java.util.ArrayList,
                 com.scalar.chiptrack.utils.ConfigManager" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/baseProductList.do"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% HttpSession ses = request.getSession(true);
  String baseProductName = (String) ses.getAttribute("baseProductName");  
   String [] fabProducts =(String [])request.getAttribute("fabProduct");
   ArrayList fabTrackId	 =(ArrayList)request.getAttribute("fabtrackList");
  //System.out.println("Fab Products "+fabProducts.length);
  ses.setAttribute("fabProduct",fabProducts);
  ses.setAttribute("fabTrackId",fabTrackId);
  %>
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<SCRIPT>
	var len = 0;
	len = "<%=fabProducts.length%>";
	var fabNames = null;
	fabNames = new Array(len);

	function whileLoad()
	{
		<%
			for( int x=0 ; x < fabProducts.length ; x++)
			{
				if( fabProducts[x]!= null && fabProducts[x].length() > 0 && !fabProducts[x].equals(""))
				{
			%>
				fabNames["<%=x%>"] = "<%=fabProducts[x]%>";
			<%	
				}
			}
		%>
	}

    function func() 
	{
		var errors='';
		var errorId = '';
		var pa;
		//alert(fabNames.length);
		xyz:
		for( var x=0 ; x < fabNames.length ; x++ )
		{
			if( fabNames[x].length > 0 )
			{
				var temp = document.sortprocess[fabNames[x]];
				var count = 0;
				errorId='errors'+x;

				for( var y=0 ; y < temp.length ; y++ )
				{
					if( temp[y].checked+"" == 'true'  )
					{
						count++;
					}
				}
				if( count == 0 )
				{
					errors = "<li> Please select atleast one Sort ";
					break xyz;
				}
			}
		}
		
		if(errors != '')
		{
			for(var l=0 ; l < fabNames.length ; l++)
			{	
				if( fabNames[l].length > 0 )
				{
					pa = document.getElementById("errors"+l);
					pa.innerHTML = "";
				}
			}
			var pa=document.getElementById(errorId);
			pa.innerHTML = errors;
			return;
		}
		document.sortprocess.submit();
    }


    if (document.layers)window.setResizable(false);
      var c = 0;

    function addMore(sortno,count) {

        // changed by hareesh on 10rh september 2003
        //var currval    = eval('document.sortprocess.sort'+sortno+'.value');
        //var curr_doc   = eval('document.sortprocess.sort'+sortno);
        var currval    = document.sortprocess['sort'+sortno].value;
        var curr_doc   = document.sortprocess['sort'+sortno];

        curr_doc.value = parseInt(currval)+1;
        //alert(curr_doc.value);
        var htmltext = '<input type="checkbox" name="'+sortno+'"  size="20" class="txfield">Sort'+currval+'<br><br>';
        var pa=document.getElementById('font'+sortno);
        pa.insertAdjacentHTML('BeforeEnd',htmltext);
    }

function cancel() 
{
	document.sortprocess.action ="<%=chipTracContext%>/baseProductList.do";
	document.sortprocess.submit();
}

</SCRIPT>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href='<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css' type='text/css' rel='stylesheet'>
</HEAD>
<BODY bgColor='#ffffff' leftMargin='0' topMargin='0' marginheight='0' marginwidth='0' onLoad='javascript:whileLoad();'>

<html:form name="sortprocess" type="com.scalar.chiptrack.operations.process.forms.SortProcessSplitForm" action="/sortprocesssplit">

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp"%>
<!-- Top Header End-->


<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->

<%@ include file="/jsp/operations/operations_menu.jsp"%>

	</TD>
<!-- end of the side navigations -->

    <TD bgcolor="#ffffff">
    <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
    <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
    <TD valign="top" width="100%"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
    <BR>
<!-- from here your body starts -->

    <center><span class="NArialW">Sort Process Setup</span></center>
    <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
    <table border='0' width='90%' align='center'>
        <tr><td colspan=2><font class="NArialL">Please enter the optional SORTS you want to do for these products
            </font></td>  </tr>
            <% 
			int errorCnt = 0;
			for(int i=0;i<fabProducts.length;i++)
            {
                if(!fabProducts[i].equals("")) {
            %>
			<tr><td colspan='2' class="NArialL" align="left"><font color="FF0000"><font id="errors<%=errorCnt%>"></font></font></td></tr>

            <tr><td colspan=2><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
            <tr>
              <td><font class="NArialL" valign=top>Fab Product Name : <%=fabProducts[i]%></font></td>
              <td><font class="NArialL">
                <input type="checkbox" name="<%=fabProducts[i]%>" size="20" class="txfield" value="off">Sort 1<br><br>
                <input type="checkbox" name="<%=fabProducts[i]%>" size="20" class="txfield" value="off">Sort 2<br><br>
                <input type="checkbox" name="<%=fabProducts[i]%>" size="20" class="txfield" value="off">Sort 3<br><br>
                <font id='font<%=fabProducts[i]%>'></font>
                <a href="javascript:addMore('<%=fabProducts[i]%>','<%=i%>')">
                <img src="<%=chipTracContext%>/jsp/includes/images/addmore.gif" border="0">
                </td>
            </tr>
            <tr><td colspan=2><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
            <tr><td colspan=2><font class="NArialL">Would you like to keep the products in the DIEBANK after Sort
            </font></td></tr>
            <tr><td colspan=2><font class="NArialL">
            <input type="radio" name="diebank<%=fabProducts[i]%>" value="0">Yes &nbsp;&nbsp;&nbsp;
            <input type="radio" name="diebank<%=fabProducts[i]%>" value="1" checked>No
            </font></td></tr>
            <tr><td colspan=2><HR width="100%" noShade SIZE=1></td></tr>
            <tr><td colspan=2><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
            <input type="hidden" name="sort<%=fabProducts[i]%>" value="4" >
           <%    errorCnt++;    }
                }
           %>
            <tr>
              <td align=center colspan=2>
			  <chiptrack:restrictedLink functionality='<%=Functionality.PRODUCT_SETUP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:func();' onmouseover="window.status='Click here to save the Sort Process';return true" onmouseout="window.status='';return true">
              <img border="0" src="<%=chipTracContext%>/jsp/includes/images/next.gif"></chiptrack:restrictedLink>
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			  <chiptrack:restrictedLink functionality='<%=Functionality.PRODUCT_SETUP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:cancel();' onmouseover="window.status='Click here to return to Product List';return true" onmouseout="window.status='';return true">
              <img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif"></chiptrack:restrictedLink></td>
        </tr>
      </table>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->

<%@ include file="/jsp/includes/footer.jsp"%>

<!-- footer end here -->
</html:form>
</BODY>
</html>